home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / music / replayers / benrpl.s < prev    next >
Encoding:
Text File  |  1980-01-04  |  34.4 KB  |  1,451 lines

  1.  
  2.     SECTION    BenReplay,CODE
  3.  
  4.     movem.l    d1-a6,-(sp)
  5.  
  6.     move.l    (execbase).w,a6
  7.     jsr    forbid(a6)
  8.  
  9.     move.w    $dff01c,d0
  10.     or.w    #$8000,d0
  11.     move.w    d0,OldIntena
  12.     move.w    #$7fff,$dff09a
  13.     move.w    #$e020,$dff09a
  14.  
  15.     bsr.w    Br_GetVBR
  16.  
  17.     lea    Mod,a0
  18.     bsr.w    Br_Init
  19.     beq.b    End
  20.     bsr.w    Br_Start
  21.  
  22.     move.w    #64,Br_FadeVolume    ; Fade in
  23.  
  24. Click:    btst    #6,$bfe001
  25.     bne.b    Click
  26.  
  27.     move.w    #-1,Br_FadeVolume    ; Fade end
  28. .Wait:
  29.     tst.w    Br_MasterVolume
  30.     bne.b    .Wait
  31.  
  32.     bsr.w    Br_End
  33.  
  34. End:
  35.     move.w    OldIntena(pc),$dff09a
  36.  
  37.     move.l    (execbase).w,a6
  38.     jsr    permit(a6)
  39.  
  40.     movem.l    (sp)+,d1-a6
  41.     rts
  42.  
  43. OldIntena:    dc.w    0
  44.  
  45. forbid        = -30-102
  46. permit        = -30-108
  47. execbase    = 4
  48.  
  49.     *********************************************************
  50.     *              * BEN REPLAY V1.0 beta *        *
  51.     *               Release date :            *
  52.     *            25.11.94, 20:35 pm...        *
  53.     *        Coded by BEN from Melting Pot        *
  54.     *********************************************************
  55.  
  56.     *********************************************************
  57.     *                            *
  58.     * This replay supports :                *
  59.     *                            *
  60.     *    - Finetuned samples                *
  61.     *    - Master volume control    with fade        *
  62.     *    - CIA Timing                    *
  63.     *    - VBR anywhere and PC independant...        *
  64.     *    0  -                  Arpeggio        *
  65.     *    12 -            Slide Tune Up/Down        *
  66.     *    3  -               Tone Portamento        *
  67.     *    4  -        Vibrato (a bit crashed...)        *
  68.     *    5  -         Portamento + Volume Slide        *
  69.     *    6  -        Vibrato + Volume Slide        *
  70.     *    9  -             Sample Offset        *
  71.     *    A  -              Volume Slide        *
  72.     *    B  -             Pattern Break        *
  73.     *    C  -                Set Volume        *
  74.     *    D  -             Jump Position        *
  75.     *    F  -                 Set Speed        *
  76.     *    E0 -                Set Filter        *
  77.     *    E12-           Fine Slide Tune Up/Down        *
  78.     *    E6 -              Loop Pattern        *
  79.     *    E9 -               Retrig Note        *
  80.     *    EAB-           Fine Volume Up/Down        *
  81.     *    EC -                  Note Cut        *
  82.     *    ED -                Note Delay        *
  83.     *    EE -             Pattern Delay        *
  84.     *                            *
  85.     *     All other effects will NEVER be implemented    *
  86.     *      because nobody uses them, and I don't want    *
  87.     *       to have more and more headaches...        *
  88.     *                            *
  89.     *    It takes about 4 scans maximum on A1200...    *
  90.     *    and much better if you've got some real FAST...    *
  91.     *                            *
  92.     *    This replay is a freeware, but if you like    *
  93.     *      it and you use it, or if you find bugs, just    *
  94.     *      write a nice letter (anything that looks like    *
  95.     *    paper) and you'll certainly get an answer.    *
  96.     *    In fact, this is a sort of PostCardware...    *
  97.     *    Anyway, you will be registered, by the will    *
  98.     *    of God...                    *
  99.     *      You also may send money... (joke, coz        *
  100.     *     I really hate those democoders who sell their    *
  101.     *      routines and other stuffs... Just lamers...)    *
  102.     *      At least, I think there are still many bugs,    *
  103.     *    so SEND me bugs report PLEEEEEAAAASE !!!    *
  104.     *                            *
  105.     *        Write to:                *
  106.     *            Benjamin LEGROS            *
  107.     *           106 rue Alexandre DETROY        *
  108.     *           59650 VILLENEUVE D'ASCQ        *
  109.     *                FRANCE            *
  110.     *                            *
  111.     * La direction décline tout responsabilité dans le cas    *
  112.     * de dommages causés par la présente routine, due à une    *
  113.     *     utilisation abusive de drogues et autres    *
  114.     *    hallucinogènes. Nous vous prions de bien vouloir    *
  115.     *     tirer la chasse d'eau en partant, et nous vous    *
  116.     *         souhaitons un agréable voyage...        *
  117.     *                            *
  118.     *                To be continued...    *
  119.     *                            *
  120.     *********************************************************
  121.  
  122.     *********************************************************
  123.     *                            *
  124.     *        How to use it ??            *
  125.     *    First, just BSR Br_Init after putting the    *
  126.     *     31 SAMPLES PROTRACKER module address in    *
  127.     *    a0 (lea    mod,a0)...                *
  128.     *    Then, when you want the module to start,    *
  129.     *    just BSR Br_Start. As it use CIA timing,    *
  130.     *    you don't have to execute the replay each    *
  131.     *     vblank... But you MUSTN'T USE TIMERS A        *
  132.     *   of the CIA-B, coz I use timer A... (anyway, don't    *
  133.     *    use CIA...)                    *
  134.     *     By the way, you have to set Level6 and master    *
  135.     *        interruptionbits in Intena ($9A).        *
  136.     *       To stop the replay, just BSR Br_End.        *
  137.     *                            *
  138.     *    You can momently stop the replay by setting    *
  139.     *     Br_PlayEna to 0. Restart the replay using    *
  140.     *    BSR Br_Start...                    *
  141.     *                            *
  142.     *     The volume control option is enabled by    *
  143.     *     setting the Br_MasterVolumeControl option    *
  144.     *    to 1 And then, move Br_MasterVolume from 0 to 64    *
  145.     *                            *
  146.     *    Br_Voice should be used if your module use    *
  147.     *      1, 2 or 3 channels (like games using SFX...)    *
  148.     *    For speedup reasons, you MUST use lower channels    *
  149.     *     (channels 1&2 for 2 channels module), and you    *
  150.     *    MUSTN'T use any effect on non-played channel(s)    *
  151.     *                            *
  152.     *      To make this routine play-able on A4000 where    *
  153.     *    VBR may be anywhere in (FAST)ram, just check    *
  154.     *        it and put it in Br_VBR, or simply call    *
  155.     *        BSR_GetVBR...                *
  156.     *                            *
  157.     *     The Converted Module player is also available    *
  158.     *            Write me !!            *
  159.     *                            *
  160.     *********************************************************
  161.  
  162. Br_MasterVolumeControl        = 1
  163. Br_Volume            = 0
  164. Br_Voice            = 4
  165. Br_TempoInit            = 125
  166. Br_FrameValue            = 14290*125    ; Frame time in CIA ticks*125
  167. Br_ReplayTime            = $180*2+180    ; about A1200 value...
  168.  
  169. *****************************************************************************
  170. Br_Start:********************************************************************
  171.     movem.l    a2/a3,-(sp)
  172.     lea    Br_Play(pc),a3
  173.     move.l    Br_VBR(pc),a2
  174.     move.w    #$400,$dff096
  175.     move.l    a3,$78(a2)
  176.     move.w    #$e020,$dff09a
  177.  
  178.     lea    $bfd000,a3
  179.  
  180.     move.b    #$7e,$d00(a3)    ; disable all timings & alarms
  181.     move.b    #$08,$e00(a3)    ; one-shot mode
  182.     move.b    #(Br_FrameValue/Br_TempoInit-Br_ReplayTime)>>8,$500(a3)    ; high
  183.     move.b    #(Br_FrameValue/Br_TempoInit-Br_ReplayTime)&$ff,$400(a3); Low
  184.  
  185. .Wait:    btst    #0,$d00(a3)    ; Repeat until no alarm A
  186.     beq.b    .Wait
  187.     move.b    #$81,$d00(a3)    ; init Timer A
  188.     move.w    #$2000,$dff09c
  189.  
  190. .Wbl1:    cmp.b    #$ff,$dff006    ; Wait good sync
  191.     bne.b    .Wbl1        ; for modules using VBLANK timer...
  192. .Wbl2:    cmp.b    #$0,$dff006    ; (tempo=125)
  193.     bne.b    .Wbl2
  194. .Wbl3:    cmp.b    #$0,$dff006
  195.     beq.b    .Wbl3
  196. .Wbl4:    cmp.b    #$0,$dff006
  197.     bne.b    .Wbl4
  198.     move.b    #$19,$e00(a3)    ; Start CIA
  199.     movem.l    (sp)+,a2/a3
  200.     rts
  201.  
  202. *****************************************************************************
  203. Br_Play:
  204.     move.w    #$00f,$dff180
  205.     movem.l    d0-a6,-(sp)
  206.     tst.b    $bfdd00
  207.     lea    Br_Infos(pc),a0
  208.     tst.w    (a0)
  209.     beq.w    Br_DontPlay
  210.     move.l    #$80000000,Br_DMACON-Br_Infos(a0)
  211.     move.l    Br_Pattern(pc),a1
  212.     lea    Br_ChannelInfo(pc),a2
  213.     lea    Br_SampleInfos(pc),a3
  214.     lea    Br_EffectNo(pc),a6
  215.     lea    $dff0a0,a5
  216.     move.w    #$400,$096-$0a0(a5)    ; Force blitter priority
  217.     moveq    #1,d6            ; DMA
  218.     moveq    #Br_Voice-1,d7
  219.  
  220.     tst.w    Br_Counter-Br_Infos(a0)
  221.     bne.w    Br_PlayOldNote
  222.  
  223. Br_PlayNewNote:
  224.     moveq    #0,d5    ; Sample Check
  225.  
  226.     move.b    (a1),d0                ; D0 = Sample
  227.     move.w    (a1)+,d1            ; D1 = Note
  228.     beq.b    .Br_PlayNewCheckEffect
  229.  
  230.     ext.w    d0                *** Check SampleDatas ***
  231.     beq.b    .Br_PlayNewDontChangeVolume
  232.     subq.w    #1,d0
  233.     lsl.w    #5,d0
  234.     move.w    d0,Br_ChOldSample(a2)
  235.     move.l    a3,d2
  236.     lea    Br_ChVol+1(a2),a4
  237.     lea    Br_SplVol(a3,d0.w),a3
  238.     move.b    (a3)+,(a4)+        ; Volume
  239.     move.l    (a3)+,(a4)+        ; Address
  240.     move.l    (a3)+,(a4)+        ; RepeatPoint
  241.     move.l    (a3)+,(a4)+        ; Length & Loop
  242.     move.l    d2,a3
  243.  
  244. .Br_PlayNewDontChangeVolume:            *** Check period & address ***
  245.     and.w    #$ff,d1
  246.     beq.b    .Br_PlayNewCheckEffect
  247.  
  248.     move.w    Br_ChOldSample(a2),d0
  249.     clr.w    Br_ChPortDest(a2)
  250.     subq.w    #2,d1
  251.     move.w    d1,Br_ChNote(a2)
  252.     move.l    Br_SplFineTablePtr(a3,d0.w),a4
  253.     move.w    (a2),Br_ChPortSource(a2) ; Br_ChPer
  254.     move.w    (a4,d1.w),(a2) ; Br_ChPer
  255.  
  256.     tst.w    Br_PtrnDelay-Br_Infos(a0)    ; Si pattern delay, pas jouer
  257.     bne.b    .Br_PlayNewCheckEffect        ; nouveau sample, mais garde
  258.                         ; la periode et autres...
  259.  
  260.     moveq    #-1,d5    ; Test ok
  261.  
  262. .Br_PlayNewCheckEffect:                *** Check effect ***
  263.     move.b    (a1),d0                ; D0 = Effect
  264.     ext.w    d0
  265.     move.w    (a1)+,d1            ; D1 = Command
  266.     move.w    d1,Br_ChEff(a2)
  267.     beq.b    .Br_PlayNewCheckNoEffect
  268.     move.w    .Br_EffectTable1(pc,d0.w),d0
  269.     jsr    (a6,d0.w)            ; A6 = Br_EffectNo
  270.     bra.b    .Br_PlayNewCheckNoEffect
  271.  
  272. .Br_EffectTable1:    ; Effets à la 1ère frame
  273.     dc.w    Br_PrepArpeggio-Br_EffectNo    ; 0-Arpeggio
  274.     dc.w    Br_EffectNo-Br_EffectNo        ; 1-Tune Up
  275.     dc.w    Br_EffectNo-Br_EffectNo        ; 2-Tune Down
  276.     dc.w    Br_PrepPortamento-Br_EffectNo    ; 3-Portamento
  277.     dc.w    Br_PrepVibrato-Br_EffectNo    ; 4-Vibrato
  278.     dc.w    Br_PrepPortVolSlide-Br_EffectNo    ; 5-Portamento + Volume Slide
  279.     dc.w    Br_PrepVibrVolSlide-Br_EffectNo    ; 6-Vibrato + Volume Slide
  280.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7 Tremolo
  281.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 8 
  282.     dc.w    Br_SampleOffset-Br_EffectNo    ; 9-Sample Offset
  283.     dc.w    Br_EffectNo-Br_EffectNo        ; A-Volume Slide
  284.     dc.w    Br_BreakSong-Br_EffectNo    ; B-Break Song
  285.     dc.w    Br_SetVolume-Br_EffectNo    ; C-Set Volume
  286.     dc.w    Br_BreakPattern-Br_EffectNo    ; D-Break Pattern
  287.     dc.w    Br_ECommands1-Br_EffectNo    ; E Others
  288.     dc.w    Br_SetSpeed-Br_EffectNo        ; F-Set Speed
  289.  
  290. .Br_PlayNewCheckNoEffect:
  291.     tst.w    d5    ; Check ok?
  292.     beq.b    .Br_PlayDontResetRegisters
  293.     bpl.b    .Br_PlayNoPer        ; Delay
  294.     move.w    d6,$dff096            ; DMACON
  295.     or.w    d6,Br_DMACON-Br_Infos(a0)
  296.     move.l    Br_ChAdr(a2),(a5)
  297.     move.w    Br_ChLen(a2),4(a5)
  298. ;    bra.b    .Br_PlayPer        ; <-----.
  299. .Br_PlayDontResetRegisters:        ;       |
  300. ;    move.b    Br_ChEff(a2),d0        ; <- Pas utile...
  301. ;    or.b    #%100,d0        ; <-----|
  302. ;    cmp.b    #12,d0            ; <-----|
  303. ;    beq.b    .Br_PlayNoPer        ; <-----'
  304. .Br_PlayPer:
  305.     move.w    (a2),6(a5) ; Br_ChPer
  306. .Br_PlayNoPer:
  307.     IFNE    Br_MasterVolumeControl
  308.     move.w    Br_ChVol(a2),d0
  309.     mulu.w    Br_MasterVolume-Br_Infos(a0),d0
  310.     lsr.w    #6,d0
  311.     move.w    d0,8(a5)
  312.     ELSE
  313.     move.w    Br_ChVol(a2),8(a5)
  314.     ENDC
  315.  
  316.     lea    16(a5),a5
  317.     lea    64(a2),a2
  318.     add.w    d6,d6            ; next DMA channel
  319.     dbf    d7,Br_PlayNewNote
  320.  
  321.     move.w    Br_Speed(pc),Br_Counter-Br_Infos(a0)
  322.  
  323.     bra.b    Br_PlayCheckCounter
  324.  
  325. Br_PlayOldNote:
  326.     move.w    Br_ChEff(a2),d1
  327.     beq.b    .Br_PlayOldDontCheck
  328.     move.b    Br_ChEff(a2),d0
  329.     ext.w    d0
  330.     move.w    .Br_EffectTable2(pc,d0.w),d0
  331.     jsr    (a6,d0.w)            ; A6 = Br_EffectNo
  332.     bra.b    .Br_PlayOldDontCheck
  333.  
  334. .Br_EffectTable2:    ; Effets à chaque frame
  335.     dc.w    Br_Arpeggio-Br_EffectNo        ; 0 Arpeggio
  336.     dc.w    Br_TuneUp-Br_EffectNo        ; 1 Tune Up
  337.     dc.w    Br_TuneDown-Br_EffectNo        ; 2 Tune Down
  338.     dc.w    Br_Portamento-Br_EffectNo    ; 3 Portamento
  339.     dc.w    Br_Vibrato-Br_EffectNo        ; 4 Vibrato
  340.     dc.w    Br_PortVolSlide-Br_EffectNo    ; 5 Portamento + Volume Slide
  341.     dc.w    Br_VibrVolSlide-Br_EffectNo    ; 6 Vibrato + Volume Slide
  342.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7 Tremolo
  343.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 8 
  344.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 9 Sample Offset
  345.     dc.w    Br_VolumeSlide-Br_EffectNo    ; A Volume Slide
  346.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; B Break Song
  347.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; C Set Volume
  348.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; D Break Pattern
  349.     dc.w    Br_ECommands2-Br_EffectNo    ; E Others
  350.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; F Set Speed
  351.  
  352. .Br_PlayOldDontCheck:
  353.     IFNE    Br_MasterVolumeControl
  354.     move.w    Br_ChVol(a2),d0
  355.     mulu.w    Br_MasterVolume-Br_Infos(a0),d0
  356.     lsr.w    #6,d0
  357.     move.w    d0,8(a5)
  358.     ENDC
  359.  
  360.     lea    64(a2),a2
  361.     lea    16(a5),a5
  362.     add.w    d6,d6
  363.     dbf    d7,Br_PlayOldNote
  364.  
  365. Br_PlayCheckCounter:
  366.     IFNE    Br_MasterVolumeControl
  367.     move.w    Br_MasterVolume(pc),d0
  368.     add.w    Br_FadeVolume(pc),d0
  369.     bge.b    .Br_PlayCheckFadeDown
  370.     clr.w    d0
  371.     bra.b    .Br_PlayCheckFadeUp
  372. .Br_PlayCheckFadeDown:
  373.     cmp.w    #64,d0
  374.     ble.b    .Br_PlayCheckFadeUp
  375.     moveq    #64,d0
  376. .Br_PlayCheckFadeUp:
  377.     move.w    d0,Br_MasterVolume-Br_Infos(a0)
  378.     ENDC
  379.  
  380.     subq.w    #1,Br_Counter-Br_Infos(a0)
  381.     bne.w    .Br_PlayEnd
  382.  
  383.     tst.w    Br_PtrnDelay-Br_Infos(a0)
  384.     beq.b    .Br_PlayPatternNotDelayed
  385.     subq.w    #1,Br_PtrnDelay-Br_Infos(a0)
  386.     beq.b    .Br_PlayPatternNotDelayed
  387.     bra.w    .Br_PlayEnd
  388.  
  389. .Br_PlayPatternNotDelayed:
  390.     tst.l    Br_Break-Br_Infos(a0)
  391.     bne.b    .Br_PlayCheckBreak
  392.  
  393.     add.l    #16,Br_Pattern-Br_Infos(a0)
  394.     addq.w    #1,Br_Note-Br_Infos(a0)
  395.     cmp.w    #64,Br_Note-Br_Infos(a0)
  396.     bne.w    .Br_PlayEnd
  397.     clr.w    Br_Note-Br_Infos(a0)
  398.     move.w    Br_Position(pc),d0
  399.     addq.w    #1,d0
  400.     cmp.b    Br_MaxPos(pc),d0
  401.     blt.b    .Br_PlayNotBottomOfSong
  402.     moveq    #0,d0
  403. .Br_PlayNotBottomOfSong:
  404.     move.w    d0,Br_Position-Br_Infos(a0)
  405.     bra.b    .Br_PlayCalcNewAddress
  406.  
  407. .Br_PlayCheckBreak:
  408.     move.w    #0,Br_Note-Br_Infos(a0)
  409.     tst.w    Br_Break-Br_Infos(a0)
  410.     beq.b    .Br_PlayBreakSong
  411.     move.w    Br_Break(pc),d1
  412.     clr.w    Br_Break-Br_Infos(a0)
  413.     not.w    d1            ; D1=New Note
  414.     cmp.w    #63,d1
  415.     ble.b    .Br_PlayTopOfPattern
  416.     moveq    #63,d1
  417. .Br_PlayTopOfPattern:
  418.     move.w    d1,Br_Note-Br_Infos(a0)
  419.     tst.w    Br_BreakSng-Br_Infos(a0)
  420.     bne.b    .Br_PlayBreakSong
  421.     move.w    Br_Position(pc),d0    ; la song n'a pas été coupée, alors
  422.     addq.w    #1,d0            ; on avance de 1 position
  423.     cmp.b    Br_MaxPos(pc),d0
  424.     blt.b    .Br_PlayBreakBottom
  425.     moveq    #0,d0
  426. .Br_PlayBreakBottom:
  427.     move.w    d0,Br_Position-Br_Infos(a0)
  428.     bra.b    .Br_PlayCalcNewAddress
  429.  
  430. .Br_PlayBreakSong:
  431.     move.w    Br_BreakSng(pc),d0
  432.     clr.w    Br_BreakSng-Br_Infos(a0)
  433.     not.w    d0            ; D0=New Pos
  434.     cmp.b    Br_MaxPos(pc),d0
  435.     blt.b    .Br_PlayBreakSongBottom
  436.     moveq    #0,d0
  437. .Br_PlayBreakSongBottom:
  438.     move.w    d0,Br_Position-Br_Infos(a0)
  439. .Br_PlayCalcNewAddress:
  440.     move.l    Br_Module(pc),a1
  441.     lea    952(a1),a1
  442.     move.b    (a1,d0.w),d0
  443.     ext.w    d0
  444.     ext.l    d0
  445.     lsl.l    #8,d0
  446.     lsl.l    #2,d0
  447.     add.l    Br_Song(pc),d0
  448.     move.w    Br_Note(pc),d1
  449.     ext.l    d1
  450.     lsl.w    #4,d1
  451.     move.l    d0,Br_LoopStartAdr-Br_Infos(a0)
  452.     add.l    d1,d0
  453.     move.l    d0,Br_Pattern-Br_Infos(a0)
  454.     clr.w    Br_LoopStartPos-Br_Infos(a0)
  455. .Br_PlayEnd:
  456.     lea    $bfd400,a0
  457.     move.b    #$01,$500-$400(a0)
  458.     move.b    #$80,(a0)
  459.     move.l    Br_VBR(pc),a2
  460.     lea    Br_Int1(pc),a3
  461.     move.l    a3,$78(a2)
  462.     move.b    #$19,$e00-$400(a0)
  463. Br_DontPlay:
  464.     movem.l    (sp)+,d0-a6
  465.     move.w    #$bbc,$dff180
  466.     move.w    #$2000,$dff09c
  467.     rte
  468.  
  469. ****************************************************************************
  470. ******************************************* Br Interrupts ******************
  471. Br_Int1:tst.w    $bfdd00
  472.     move.l    a0,-(sp)
  473.     move.l    Br_VBR(pc),a0
  474.     add.l    #Br_Int2-Br_Int1,$78(a0)
  475.     lea    $dff096,a0
  476.     move.w    Br_DMACON(pc),(a0)
  477.     move.b    #$19,$bfde00
  478.     move.w    #$2000,$9c-$96(a0)
  479.     move.l    (sp)+,a0
  480.     rte
  481.  
  482. Br_Int2:movem.l    d0/a2/a6,-(sp)
  483.     lea    $dff0a0,a6
  484.     lea    Br_ChannelInfo+Br_ChRP(pc),a2
  485.     move.l    (a2),(a6)
  486.     move.w    Br_ChRLen-Br_ChRP(a2),$4(a6)
  487.     move.l    64(a2),$10(a6)
  488.     move.w    Br_ChRLen-Br_ChRP+64(a2),$14(a6)
  489.     move.l    128(a2),$20(a6)
  490.     move.w    Br_ChRLen-Br_ChRP+128(a2),$24(a6)
  491.     move.l    192(a2),$30(a6)
  492.     move.w    Br_ChRLen-Br_ChRP+192(a2),$34(a6)
  493.     move.l    Br_VBR(pc),a2
  494.     add.l    #Br_Play-Br_Int2,$78(a2)
  495.     move.w    Br_CIATimer(pc),d0        ; CIA init
  496.     lea    $bfd000,a2
  497.     tst.w    $d00(a2)
  498.     move.b    d0,$400(a2)
  499.     rol.w    #8,d0
  500.     move.b    d0,$500(a2)
  501.     move.b    #$19,$e00(a2)
  502.     move.w    #$2000,$09c-$0a0(a6)
  503.     movem.l    (sp)+,d0/a2/a6
  504.     rte
  505.  
  506. ****************************************************************************
  507. ****************************************** Br Effects **********************
  508. Br_ECommands1:                ; E Check    *
  509.     move.w    d1,d0
  510.     and.w    #$f,d1
  511.     lsr.b    #4,d0
  512.     ext.w    d0
  513.     add.w    d0,d0
  514.     move.w    Br_E_EffectTable1(pc,d0.w),d0
  515.     jmp    (a6,d0.w)            ; A6 = Br_EffectNo
  516. Br_E_EffectTable1:
  517.     dc.w    Br_SetFilter-Br_EffectNo    ; 0-Filter
  518.     dc.w    Br_FineTuneUp-Br_EffectNo    ; 1-FineTune Up
  519.     dc.w    Br_FineTuneDown-Br_EffectNo    ; 2-FineTune Down
  520.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 3
  521.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 4
  522.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 5
  523.     dc.w    Br_LoopPattern-Br_EffectNo    ; 6 Loop
  524.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7
  525.     dc.w    Br_CheckEvent-Br_EffectNo    ; 8
  526.     dc.w    Br_PrepRetrigNote-Br_EffectNo    ; 9-Retrig Note
  527.     dc.w    Br_FineVolumeUp-Br_EffectNo    ; A-FineVolume Up
  528.     dc.w    Br_FineVolumeDown-Br_EffectNo    ; B-FineVolume Down
  529.     dc.w    Br_EffectNo-Br_EffectNo        ; C-NoteCut
  530.     dc.w    Br_PrepDelayNote-Br_EffectNo    ; D-NoteDelay
  531.     dc.w    Br_PatternDelay-Br_EffectNo    ; E PatternDelay
  532.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; F
  533.  
  534. Br_ECommands2:                ; E Check    *
  535.     move.w    d1,d0
  536.     and.w    #$f,d1
  537.     lsr.b    #4,d0
  538.     ext.w    d0
  539.     add.w    d0,d0
  540.     move.w    Br_E_EffectTable2(pc,d0.w),d0
  541.     jmp    (a6,d0.w)            ; A6 = Br_EffectNo
  542. Br_E_EffectTable2:
  543.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 0 Filter
  544.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 1 FineTune Up
  545.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 2 FineTune Down
  546.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 3
  547.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 4
  548.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 5
  549.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 6 Loop
  550.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 7
  551.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; 8
  552.     dc.w    Br_RetrigNote-Br_EffectNo    ; 9 Retrig Note
  553.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; A FineVolume Up
  554.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; B FineVolume Down
  555.     dc.w    Br_NoteCut-Br_EffectNo        ; C NoteCut
  556.     dc.w    Br_DelayNote-Br_EffectNo    ; D NoteDelay
  557.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; E PatternDelay
  558.     dc.w    Br_EffectDisconnect-Br_EffectNo    ; F
  559.  
  560. Br_EffectNo:
  561.     rts
  562.  
  563. Br_EffectDisconnect:
  564.     clr.w    Br_ChEff(a2)
  565.     rts
  566.  
  567. Br_PrepArpeggio:            ; 0
  568.     move.b    d1,d0
  569.     and.w    #$f,d1
  570.     add.w    d1,d1
  571.     add.w    Br_ChNote(a2),d1
  572.     lsr.b    #4,d0
  573.     ext.w    d0
  574.     add.w    d0,d0
  575.     add.w    Br_ChNote(a2),d0
  576.     move.w    Br_ChOldSample(a2),d2
  577.     move.l    Br_SplFineTablePtr(a3,d2.w),a4
  578.     move.w    (a4,d0.w),Br_ChArp1(a2)
  579.     move.w    (a4,d1.w),Br_ChArp2(a2)
  580.     move.w    (a2),Br_ChArp3(a2) ; Br_ChPer
  581.     rts
  582.  
  583. Br_Arpeggio:                ; 0
  584.     move.w    Br_ChArp1(a2),d0
  585.     move.w    d0,6(a5)
  586.     move.l    Br_ChArp2(a2),Br_ChArp1(a2)
  587.     move.w    d0,Br_ChArp3(a2)
  588.     rts
  589.  
  590. Br_TuneUp:                ; 1
  591.     and.w    #$ff,d1
  592.     move.w    (a2),d0 ; Br_ChPer
  593.     sub.w    d1,d0
  594.     cmp.w    #107,d0
  595.     bgt.b    .Br_TuneUp_0
  596.     move.w    #108,d0
  597.     clr.w    Br_ChEff(a2)
  598. .Br_TuneUp_0:
  599.     move.w    d0,(a2) ; Br_ChPer
  600.     move.w    d0,6(a5)
  601.     rts
  602.  
  603. Br_TuneDown:                ; 2
  604.     and.w    #$ff,d1
  605.     move.w    (a2),d0    ; Br_ChPer
  606.     add.w    d1,d0
  607.     cmp.w    #908,d0
  608.     blt.b    .Br_TuneDown_0
  609.     move.w    #907,d0
  610.     clr.w    Br_ChEff(a2)
  611. .Br_TuneDown_0:
  612.     move.w    d0,(a2)    ; Br_ChPer
  613.     move.w    d0,6(a5)
  614.     rts
  615.  
  616. Br_PrepPortamento:            ; 3
  617.     tst.b    d1
  618.     beq.b    .Br_PrepPortamento_0
  619.     move.b    d1,Br_ChPortamento+1(a2)
  620. .Br_PrepPortamento_0:
  621.     tst.w    d5                ; Si on joue une nouvelle
  622.     beq.b    .Br_PrepPortamento_1        ; note, il faut swapper les
  623.     move.w    (a2),Br_ChPortDest(a2)        ; périodes, car la nouvelle
  624.     move.w    Br_ChPortSource(a2),(a2)    ; note est la DESTINATION
  625.     moveq    #0,d5                ; Et pas de nouveau sample...
  626. .Br_PrepPortamento_1:
  627.     rts
  628.  
  629. Br_Portamento:                ; 3
  630.     move.w    Br_ChPortDest(a2),d1
  631.     beq.b    .Br_NoPortamento
  632.     move.w    (a2),d2    ; Br_ChPer
  633.     cmp.w    d1,d2
  634.     beq.b    .Br_NoPortamento
  635.     blt.b    .Br_Portamento_1    ; Si Periode<Destina0, Sub Portam,Per
  636. .Br_Portamento_0:
  637.     sub.w    Br_ChPortamento(a2),d2
  638.     cmp.w    d1,d2
  639.     bgt.b    .Br_EndPortamento
  640.     move.w    d1,d2
  641.     clr.w    Br_ChEff(a2)
  642.     bra.b    .Br_EndPortamento
  643. .Br_Portamento_1:
  644.     add.w    Br_ChPortamento(a2),d2
  645.     cmp.w    d1,d2
  646.     blt.b    .Br_EndPortamento
  647.     move.w    d1,d2
  648.     clr.w    Br_ChEff(a2)
  649. .Br_EndPortamento:
  650.     move.w    d2,(a2)    ; Br_ChPer
  651.     move.w    d2,6(a5)
  652. .Br_NoPortamento:
  653.     rts
  654.  
  655. Br_PrepVibrato:                ; 4
  656.     move.w    d1,d0
  657.     and.b    #$f,d1            ; D1 = VibratoDepth
  658.     beq.b    .Br_PrepVibrato_0
  659.     move.b    d1,Br_ChVibratoDepth+1(a2)
  660. .Br_PrepVibrato_0:
  661.     lsr.b    #4,d0            ; D0 = VibratoSpeed
  662.     ext.w    d0
  663.     add.w    d0,d0
  664.     beq.b    .Br_PrepVibrato_1
  665.     move.w    d0,Br_ChVibratoSpeed(a2)
  666. .Br_PrepVibrato_1:
  667.     rts
  668.  
  669. Br_Vibrato:                ; 4
  670.     move.w    Br_ChVibratoPos(a2),d0
  671.     lea    Br_VibratoTable(pc),a4
  672.     move.w    (a4,d0.w),d1
  673.     muls.w    Br_ChVibratoDepth(a2),d1
  674.     lsr.l    #7,d1
  675.     add.w    (a2),d1
  676.     move.w    d1,6(a5)
  677.     add.w    Br_ChVibratoSpeed(a2),d0
  678.     and.w    #126,d0
  679.     move.w    d0,Br_ChVibratoPos(a2)
  680.     rts
  681.  
  682. Br_PrepPortVolSlide:            ; 5
  683.     clr.w    d1
  684.     bra.w    Br_PrepPortamento
  685.  
  686. Br_PortVolSlide:            ; 5
  687.     move.b    d1,d0
  688.     beq.b    .Br_NoVolumeSlide
  689.     and.w    #$f,d0
  690.     move.w    Br_ChVol(a2),d2
  691.     lsr.b    #4,d1
  692.     ext.w    d1
  693.     bne.b    .Br_VolumeSlideUp
  694.     sub.w    d0,d2
  695.     bge.b    .Br_VolumeSlideEnd
  696.     clr.w    Br_ChVol(a2)
  697.     IFEQ    Br_MasterVolumeControl
  698.     move.w    #0,8(a5)
  699.     ENDC
  700.     bra.b    .Br_NoVolumeSlide
  701. .Br_VolumeSlideUp:
  702.     add.w    d1,d2
  703.     cmp.w    #64,d2
  704.     ble.b    .Br_VolumeSlideEnd
  705.     moveq    #64,d0
  706.     move.w    d0,Br_ChVol(a2)
  707.     IFEQ    Br_MasterVolumeControl
  708.     move.w    d0,8(a5)
  709.     ENDC
  710.     bra.b    .Br_NoVolumeSlide
  711. .Br_VolumeSlideEnd:
  712.     move.w    d2,Br_ChVol(a2)
  713.     IFEQ    Br_MasterVolumeControl
  714.     move.w    d2,8(a5)
  715.     ENDC
  716. .Br_NoVolumeSlide:
  717.     move.w    Br_ChPortDest(a2),d1
  718.     beq.b    .Br_NoPortamento
  719.     move.w    (a2),d2    ; Br_ChPer
  720.     cmp.w    d1,d2
  721.     beq.b    .Br_NoPortamento
  722.     blt.b    .Br_Portamento_1    ; Si Periode<Destina0, Sub Portam,Per
  723. .Br_Portamento_0:
  724.     sub.w    Br_ChPortamento(a2),d2
  725.     cmp.w    d1,d2
  726.     bgt.b    .Br_EndPortamento
  727.     move.w    d1,d2
  728.     bra.b    .Br_EndPortamento
  729. .Br_Portamento_1:
  730.     add.w    Br_ChPortamento(a2),d2
  731.     cmp.w    d1,d2
  732.     blt.b    .Br_EndPortamento
  733.     move.w    d1,d2
  734. .Br_EndPortamento:
  735.     move.w    d2,(a2)    ; Br_ChPer
  736.     move.w    d2,6(a5)
  737. .Br_NoPortamento:
  738.     rts
  739.  
  740. Br_PrepVibrVolSlide:            ; 6
  741.     clr.w    d1
  742.     bra.w    Br_PrepVibrato
  743.  
  744. Br_VibrVolSlide:            ; 6
  745.     move.b    d1,d0
  746.     beq.b    .Br_NoVolumeSlide
  747.     and.w    #$f,d0
  748.     move.w    Br_ChVol(a2),d2
  749.     lsr.b    #4,d1
  750.     ext.w    d1
  751.     bne.b    .Br_VolumeSlideUp
  752.     sub.w    d0,d2
  753.     bge.b    .Br_VolumeSlideEnd
  754.     clr.w    Br_ChVol(a2)
  755.     IFEQ    Br_MasterVolumeControl
  756.     move.w    #0,8(a5)
  757.     ENDC
  758.     bra.b    .Br_NoVolumeSlide
  759. .Br_VolumeSlideUp:
  760.     add.w    d1,d2
  761.     cmp.w    #64,d2
  762.     ble.b    .Br_VolumeSlideEnd
  763.     moveq    #64,d0
  764.     move.w    d0,Br_ChVol(a2)
  765.     IFEQ    Br_MasterVolumeControl
  766.     move.w    d0,8(a5)
  767.     ENDC
  768.     bra.b    .Br_NoVolumeSlide
  769. .Br_VolumeSlideEnd:
  770.     move.w    d2,Br_ChVol(a2)
  771.     IFEQ    Br_MasterVolumeControl
  772.     move.w    d2,8(a5)
  773.     ENDC
  774. .Br_NoVolumeSlide:
  775.     bra.w    Br_Vibrato
  776.  
  777. Br_SampleOffset:            ; 9
  778.     and.w    #$ff,d1
  779.     beq.b    .Br_SampleOffset_0
  780.     lsl.w    #7,d1
  781.     move.w    d1,Br_ChSampleOffset(a2)
  782.     bra.b    .Br_SampleOffset_01
  783. .Br_SampleOffset_0:
  784.     move.w    Br_ChSampleOffset(a2),d1
  785. .Br_SampleOffset_01:
  786.     ext.l    d1
  787.     moveq    #0,d0
  788.     move.l    Br_ChAdr(a2),d2
  789.     move.l    d2,d4
  790.     move.w    Br_ChLen(a2),d0
  791.     add.w    d0,d0
  792.     add.l    d0,d2            ; D2 = Sample MaxAddress
  793.     sub.w    d1,Br_ChLen(a2)        ; New SampleLength
  794.     add.w    d1,d1
  795.     add.l    d1,d4
  796.     move.l    d4,Br_ChAdr(a2)        ; D0 = Sample New StartAddress
  797.     cmp.l    d4,d2
  798.     bgt.b    .Br_SampleOffset_1
  799.     move.l    Br_ChRP(a2),Br_ChAdr(a2)
  800.     move.w    Br_ChRLen(a2),Br_ChLen(a2)
  801. .Br_SampleOffset_1:
  802.     clr.w    Br_ChEff(a2)
  803.     rts
  804.  
  805. Br_VolumeSlide:                ; A
  806.     move.b    d1,d0
  807.     beq.b    .Br_NoVolumeSlide
  808.     and.w    #$f,d0
  809.     move.w    Br_ChVol(a2),d2
  810.     lsr.b    #4,d1
  811.     ext.w    d1
  812.     bne.b    .Br_VolumeSlideUp
  813.     sub.w    d0,d2
  814.     bge.b    .Br_VolumeSlideEnd
  815.     clr.w    Br_ChVol(a2)
  816.     IFEQ    Br_MasterVolumeControl
  817.     move.w    #0,8(a5)
  818.     ENDC
  819.     clr.w    Br_ChEff(a2)
  820.     rts
  821. .Br_VolumeSlideUp:
  822.     add.w    d1,d2
  823.     cmp.w    #64,d2
  824.     ble.b    .Br_VolumeSlideEnd
  825.     moveq    #64,d0
  826.     move.w    d0,Br_ChVol(a2)
  827.     IFEQ    Br_MasterVolumeControl
  828.     move.w    d0,8(a5)
  829.     ENDC
  830.     clr.w    Br_ChEff(a2)
  831.     rts
  832. .Br_VolumeSlideEnd:
  833.     move.w    d2,Br_ChVol(a2)
  834.     IFEQ    Br_MasterVolumeControl
  835.     move.w    d2,8(a5)
  836.     ENDC
  837. .Br_NoVolumeSlide:
  838.     rts
  839.  
  840. Br_BreakSong:                ; B
  841.     and.w    #$ff,d1
  842.     not.w    d1
  843.     move.w    d1,Br_BreakSng-Br_Infos(a0)
  844.     clr.w    Br_ChEff(a2)
  845.     rts
  846.  
  847. Br_SetVolume:                ; C
  848.     move.b    d1,Br_ChVol+1(a2)
  849.     clr.w    Br_ChEff(a2)
  850.     rts
  851.  
  852. Br_BreakPattern:            ; D
  853.     move.w    d1,d0
  854.     lsr.b    #4,d0
  855.     ext.w    d0
  856.     and.w    #$f,d1
  857.     mulu.w    #10,d0
  858.     add.w    d1,d0
  859.     not.w    d0
  860.     move.w    d0,Br_Break-Br_Infos(a0)
  861.     clr.w    Br_ChEff(a2)
  862.     rts
  863.  
  864. Br_SetSpeed:                ; F
  865.     tst.b    d1
  866.     bne.b    .Br_SetSpeed_0
  867.     clr.w    (a0)
  868.     rts
  869. .Br_SetSpeed_0:
  870.     cmp.b    #31,d1
  871.     bhi.b    .Br_SetCIATiming
  872.     move.b    d1,Br_Speed+1-Br_Infos(a0)
  873.     clr.w    Br_ChEff(a2)
  874.     rts
  875. .Br_SetCIATiming:
  876.     move.l    #Br_FrameValue,d0
  877.     and.w    #$ff,d1
  878.     divu.w    d1,d0
  879.     sub.w    #Br_ReplayTime,d0
  880.     move.w    d1,Br_Tempo-Br_Infos(a0)
  881.     move.w    d0,Br_CIATimer-Br_Infos(a0)
  882.     clr.w    Br_ChEff(a2)
  883.     rts
  884.  
  885. Br_SetFilter                ; E0
  886.     tst.b    d1
  887.     beq.b    .Br_FilterOn
  888. .Br_FilterOff:
  889.     bset    #1,$bfe001
  890.     clr.w    Br_ChEff(a2)
  891.     rts
  892. .Br_FilterOn:
  893.     bclr    #1,$bfe001
  894.     clr.w    Br_ChEff(a2)
  895.     rts
  896.  
  897. Br_FineTuneUp:                ; E1
  898.     move.w    (a2),d0    ; Br_ChPer
  899.     sub.w    d1,d0
  900.     cmp.w    #107,d0
  901.     bgt.b    .Br_FineTuneUp_0
  902.     move.w    #108,d0
  903. .Br_FineTuneUp_0:
  904.     move.w    d0,(a2)    ; Br_ChPer
  905.     clr.w    Br_ChEff(a2)
  906.     rts
  907.  
  908. Br_FineTuneDown:            ; E2
  909.     move.w    (a2),d0    ; Br_ChPer
  910.     add.w    d1,d0
  911.     cmp.w    #908,d0
  912.     blt.b    .Br_FineTuneDown_0
  913.     move.w    #907,d0
  914. .Br_FineTuneDown_0:
  915.     move.w    d0,(a2)    ; Br_ChPer
  916.     clr.w    Br_ChEff(a2)
  917.     rts
  918.  
  919. Br_LoopPattern:                ; E6    *
  920.     clr.w    Br_ChEff(a2)
  921.     tst.w    Br_LoopTest-Br_Infos(a0)
  922.     bne.b    .Br_EndLoop
  923.     not.w    Br_LoopTest-Br_Infos(a0)
  924.     tst.b    d1
  925.     beq.b    .Br_PrepLoop
  926.     tst.w    Br_LoopPatternVal-Br_Infos(a0)    ; Y-a-t'il une boucle en cours?
  927.     beq.b    .Br_InitLoop
  928.     subq.w    #1,Br_LoopPatternVal-Br_Infos(a0)
  929.     beq.b    .Br_EndLoop
  930.     move.l    Br_LoopStartAdr(pc),Br_Pattern-Br_Infos(a0)
  931.     move.w    Br_LoopStartPos(pc),Br_Note-Br_Infos(a0)
  932. .Br_EndLoop:
  933.     rts
  934. .Br_InitLoop:
  935.     move.w    d1,Br_LoopPatternVal-Br_Infos(a0)
  936.     move.l    Br_LoopStartAdr(pc),Br_Pattern-Br_Infos(a0)
  937.     move.w    Br_LoopStartPos(pc),Br_Note-Br_Infos(a0)
  938.     rts
  939.  
  940. .Br_PrepLoop:
  941.     move.l    Br_Pattern(pc),Br_LoopStartAdr-Br_Infos(a0)
  942.     sub.l    #16,Br_LoopStartAdr-Br_Infos(a0)
  943.     move.w    Br_Note(pc),Br_LoopStartPos-Br_Infos(a0)
  944.     subq.w    #1,Br_LoopStartPos-Br_Infos(a0)
  945. .Br_PrepNoLoop:
  946.     rts
  947.  
  948. Br_CheckEvent:                ; E8
  949.     lea    Br_EventTable(pc),a4    ; Fonction usable for synchro
  950.     add.w    d1,d1            ; demo parts... Just check the
  951.     move.w    #-1,(a4,d1.w)        ; good event in your own code, and
  952.     clr.w    Br_ChEff(a2)        ; jump if ok... You should put E8x in
  953.     rts                ; your module where you wanna break...
  954.  
  955. Br_PrepRetrigNote:            ; E9
  956.     or.b    #$90,d1
  957.     move.b    d1,Br_ChTempValue(a2)
  958.     rts
  959.  
  960. Br_RetrigNote:                ; E9    *
  961.     subq.b    #1,d1
  962.     bne.b    .Br_RetrigNote_0
  963.     move.w    d6,$dff096            ; DMACON
  964.     or.w    d6,Br_DMACON-Br_Infos(a0)
  965.     move.l    Br_ChAdr(a2),(a5)
  966.     move.w    Br_ChLen(a2),4(a5)
  967.     move.b    Br_ChTempValue(a2),Br_ChCommand(a2)
  968.     rts
  969. .Br_RetrigNote_0:
  970.     subq.b    #1,Br_ChCommand(a2)
  971.     rts
  972.  
  973. Br_FineVolumeUp:            ; EA
  974.     move.w    Br_ChVol(a2),d2
  975.     add.w    d1,d2
  976.     cmp.w    #64,d2
  977.     ble.b    .Br_FineVolumeUp_0
  978.     moveq    #64,d2
  979. .Br_FineVolumeUp_0:
  980.     move.w    d2,Br_ChVol(a2)
  981.     IFEQ    Br_MasterVolumeControl
  982.     move.w    d2,8(a5)
  983.     ENDC
  984.     clr.w    Br_ChEff(a2)
  985.     rts
  986.  
  987. Br_FineVolumeDown:            ; EB
  988.     move.w    Br_ChVol(a2),d2
  989.     sub.w    d1,d2
  990.     bge.b    .Br_FineVolumeDown_0
  991.     moveq    #0,d2
  992. .Br_FineVolumeDown_0:
  993.     move.w    d2,Br_ChVol(a2)
  994.     IFEQ    Br_MasterVolumeControl
  995.     move.w    d2,8(a5)
  996.     ENDC
  997.     clr.w    Br_ChEff(a2)
  998.     rts
  999.  
  1000. Br_NoteCut:                ; EC
  1001.     subq.w    #1,d1
  1002.     bne.b    .Br_NoteCut_0
  1003.     clr.w    Br_ChVol(a2)
  1004.     IFEQ    Br_MasterVolumeControl
  1005.     move.w    #0,8(a5)
  1006.     ENDC
  1007.     clr.w    Br_ChEff(a2)
  1008.     rts
  1009. .Br_NoteCut_0:
  1010.     subq.b    #1,Br_ChCommand(a2)
  1011.     rts
  1012.  
  1013. Br_PrepDelayNote:            ; ED    *
  1014.     moveq    #1,d5
  1015.     tst.b    d1
  1016.     beq.b    Br_DoDelay
  1017.     rts
  1018.  
  1019. Br_DelayNote:
  1020.     subq.b    #1,d1
  1021.     bne.b    Br_DelayNote_0
  1022. Br_DoDelay:
  1023.     move.w    d6,$dff096            ; DMACON
  1024.     or.w    d6,Br_DMACON-Br_Infos(a0)
  1025.     move.w    (a2),6(a5)
  1026.     move.l    Br_ChAdr(a2),(a5)
  1027.     move.w    Br_ChLen(a2),4(a5)
  1028.     IFEQ    Br_MasterVolumeControl
  1029.     move.w    Br_ChVol(a2),8(a5)
  1030.     ENDC
  1031.     clr.w    Br_ChEff(a2)
  1032.     rts
  1033. Br_DelayNote_0:
  1034.     subq.b    #1,Br_ChCommand(a2)
  1035.     rts
  1036.  
  1037. Br_PatternDelay:            ; EE
  1038.     tst.w    Br_PtrnDelay-Br_Infos(a0)
  1039.     bne.b    .Br_PatternDelayIsAlreadyActive
  1040.     addq.w    #1,d1
  1041.     move.w    d1,Br_PtrnDelay-Br_Infos(a0)
  1042. .Br_PatternDelayIsAlreadyActive:
  1043.     clr.w    Br_ChEff(a2)
  1044.     rts
  1045.  
  1046. ******************************************************************************
  1047. Br_Init:**********************************************************************
  1048.     movem.l    d1-a6,-(sp)
  1049.     moveq    #0,d0
  1050.     lea    Br_Infos(pc),a1
  1051.     move.l    a0,Br_Module-Br_Infos(a1)
  1052.     clr.w    (a1)
  1053.     cmp.l    #'M.K.',1080(a0)    ; Si module 31 samples, Ok, joue
  1054.     beq.w    .Br_InitOk
  1055.     cmp.l    #'Fuck',1080(a0)    ; Si pas module déjà converti...
  1056.     bne.w    .Br_InitEnd        ; mange ton bras.
  1057. .Br_InitOk:
  1058.     subq.w    #1,(a1)
  1059.  
  1060.     bset    #1,$bfe001
  1061.  
  1062.     move.w    $dff002,d0
  1063.     or.w    #$8000,d0
  1064.     move.w    d0,Br_OldDMACON-Br_Infos(a1)
  1065.  
  1066.     move.w    #$000f,$dff096
  1067.  
  1068.     move.b    950(a0),Br_MaxPos-Br_Infos(a1)
  1069.  
  1070.     moveq    #0,d0
  1071.     moveq    #127,d7
  1072.     lea    952(a0),a2
  1073. .Br_InitFindMaxPat:            ; trouver la pattern maximale
  1074.     cmp.b    (a2)+,d0
  1075.     bge.b    .Br_InitNotMaxPat
  1076.     move.b    -1(a2),d0
  1077. .Br_InitNotMaxPat:
  1078.     dbf    d7,.Br_InitFindMaxPat
  1079.  
  1080.     move.b    d0,Br_MaxPat-Br_Infos(a1)
  1081.  
  1082.     addq.l    #4,a2            ; A2 = SongData pointer
  1083.  
  1084.     move.l    a2,Br_Song-Br_Infos(a1)
  1085.  
  1086.     moveq    #0,d1            ; Yes, go somewhere else...
  1087.     move.b    d0,d1
  1088.     addq.w    #1,d1
  1089.     lsl.l    #8,d1
  1090.     lsl.l    #2,d1
  1091.     move.l    a2,a4
  1092.     add.l    d1,a4
  1093.  
  1094.     cmp.l    #'Fuck',1080(a0)    ; Module has already been converted?
  1095.     beq.b    .Br_InitPatEnd        ; No, convert
  1096.  
  1097. .Br_InitCheckPat:
  1098.  
  1099.     move.w    (a2),d1
  1100.     move.w    d1,d2
  1101.     lsr.w    #8,d2        ; D2 = Sample
  1102.     and.b    #$f0,d2
  1103.  
  1104.     move.w    2(a2),d3
  1105.     move.w    d3,d4        ; D4 = Effet + Commande
  1106.     and.w    #$0fff,d4    
  1107.     eor.w    d4,d3
  1108.     rol.w    #4,d3
  1109.     or.b    d3,d2
  1110.  
  1111.     move.w    #$ff00,d5
  1112.     and.w    d4,d5
  1113.     add.w    d5,d5
  1114.     cmp.w    #($c*2)<<8,d5
  1115.     bne.b    .Br_InitNotSetVolume
  1116.     cmp.b    #64,d4
  1117.     bls.b    .Br_InitNotSetVolume
  1118.     moveq    #64,d4
  1119. .Br_InitNotSetVolume:
  1120.     move.b    d4,d5
  1121.  
  1122. .Br_InitTestNote:
  1123.     and.w    #$0fff,d1    ; D1 = Note
  1124.     beq.b    .Br_InitPutToSong
  1125.  
  1126.     lea    Br_Period0-Br_Infos(a1),a3
  1127.     moveq    #0,d3
  1128. .Br_InitFindGoodNote:
  1129.     addq.w    #1,d3
  1130.     cmp.w    #37,d3
  1131.     bge.b    .Br_InitNoteFoundOrNot
  1132.     cmp.w    (a3)+,d1
  1133.     bne.b    .Br_InitFindGoodNote
  1134. .Br_InitNoteFoundOrNot:
  1135.     add.b    d3,d3
  1136.     move.b    d3,d1
  1137.  
  1138. .Br_InitPutToSong:
  1139.     move.b    d2,(a2)+
  1140.     move.b    d1,(a2)+
  1141.     move.w    d5,(a2)+
  1142.     cmp.l    a2,a4
  1143.     bne.b    .Br_InitCheckPat
  1144. .Br_InitPatEnd:
  1145.  
  1146.     move.l    a4,a2
  1147.     move.l    a2,Br_Sample-Br_Infos(a1)
  1148.  
  1149.     move.l    #'Fuck',1080(a0)    ; the Army
  1150.  
  1151.     move.w    #0,$dff0a8
  1152.     move.w    #0,$dff0b8
  1153.     move.w    #0,$dff0c8
  1154.     move.w    #0,$dff0d8
  1155.  
  1156.     move.w    #$000f,$dff096
  1157.  
  1158.     moveq    #30,d7
  1159.     lea    42(a0),a3
  1160.     lea    Br_SampleInfos(pc),a4
  1161.  
  1162. .Br_InitSampleInit:
  1163.     move.l    a2,Br_SplAdr(a4)    ; Sample Start Address
  1164.     moveq    #0,d0
  1165.     move.b    2(a3),d0
  1166.     move.b    d0,(a4)        ; Finetune
  1167.     move.b    3(a3),Br_SplVol(a4)    ; Volume
  1168.  
  1169.     lea    Br_Period0(pc),a5
  1170.     mulu.w    #36*2,d0
  1171.     lea    (a5,d0.w),a5
  1172.     move.l    a5,Br_SplFineTablePtr(a4)
  1173.  
  1174.     moveq    #0,d0
  1175.     move.w    4(a3),d0
  1176.     add.l    d0,d0
  1177.     add.l    a2,d0
  1178.     move.l    d0,Br_SplRP(a4)        ; RepeatPoint address
  1179.  
  1180.     moveq    #0,d1
  1181.     move.w    6(a3),d1
  1182.     move.w    d1,Br_SplRLen(a4)    ; RepeatLen
  1183.  
  1184.     tst.w    (a3)
  1185.     beq.b    .Br_InitSampleInit_0
  1186.  
  1187.     cmp.l    d0,a2
  1188.     beq.b    .Br_InitSampleInit_1
  1189.  
  1190. .Br_InitSampleInit_0:
  1191.     add.l    d1,d1
  1192.     add.l    d1,d0            ; EndLoop Address
  1193.     sub.l    a2,d0
  1194.     lsr.l    #1,d0
  1195.     move.w    d0,Br_SplLen(a4)    ; FirstPass Len
  1196.     bra.b    .Br_InitSampleInit_2
  1197.  
  1198. .Br_InitSampleInit_1:
  1199.     move.w    (a3),Br_SplLen(a4)    ; FirstPass Len
  1200.  
  1201. .Br_InitSampleInit_2:
  1202.     moveq    #0,d0
  1203.     move.w    (a3),d0            ; Look for next Sample address
  1204.     add.l    d0,d0
  1205.     add.l    d0,a2
  1206.  
  1207.     lea    32(a4),a4
  1208.     lea    30(a3),a3
  1209.     dbf    d7,.Br_InitSampleInit
  1210.  
  1211.     move.w    #Br_TempoInit,Br_Tempo-Br_Infos(a1)
  1212.  move.w    #(Br_FrameValue/Br_TempoInit)-Br_ReplayTime,Br_CIATimer-Br_Infos(a1)
  1213.     move.w    #6,Br_Speed-Br_Infos(a1)
  1214.  
  1215.     move.w    Br_StartPos(pc),Br_Position-Br_Infos(a1)
  1216.     move.w    Br_StartNote(pc),Br_Note-Br_Infos(a1)
  1217.     clr.w    Br_Counter-Br_Infos(a1)
  1218.     clr.l    Br_Break-Br_Infos(a1)
  1219.     clr.l    Br_PtrnDelay-Br_Infos(a1)
  1220.  
  1221.     move.w    Br_Position(pc),d0    ; Init pattern pointer
  1222.     add.w    #952,d0
  1223.     move.b    (a0,d0.w),d0
  1224.     ext.w    d0
  1225.     ext.l    d0
  1226.     lsl.l    #8,d0
  1227.     lsl.l    #2,d0
  1228.     add.l    Br_Song(pc),d0
  1229.     move.w    Br_Note(pc),d1
  1230.     ext.l    d1
  1231.     lsl.w    #4,d1
  1232.     add.l    d1,d0
  1233.     move.l    d0,Br_Pattern-Br_Infos(a1)
  1234.     move.l    d0,Br_LoopStartAdr-Br_Infos(a1)
  1235.     clr.w    Br_LoopStartPos-Br_Infos(a1)
  1236.  
  1237.     move.l    Br_VBR(pc),a4
  1238.     move.l    $78(a4),Br_Old78-Br_Infos(a1)
  1239.  
  1240.     lea    Br_EventTable(pc),a4
  1241.     REPT    4
  1242.     clr.l    (a4)+
  1243.     ENDR
  1244.  
  1245.     lea    Br_ChannelInfo+64*4(pc),a0
  1246.     moveq    #0,d0
  1247.     moveq    #0,d1
  1248.     moveq    #0,d2
  1249.     moveq    #0,d3
  1250.     moveq    #0,d4
  1251.     moveq    #0,d5
  1252.     moveq    #0,d6
  1253.     moveq    #0,d7
  1254.  
  1255.     REPT    8
  1256.     movem.l    d0-d7,-(a0)
  1257.     ENDR
  1258.  
  1259.     moveq    #-1,d0
  1260. .Br_InitEnd:
  1261.     movem.l    (sp)+,d1-a6
  1262.     rts
  1263.  
  1264. *****************************************************************************
  1265. Br_End:**********************************************************************
  1266.     move.l    a0,-(sp)
  1267.     lea    Br_Infos,a0
  1268.     moveq    #0,d0
  1269.     move.w    d0,(a0)
  1270.     move.w    Br_OldDMACON(pc),$dff096
  1271.     move.l    Br_VBR(pc),a0
  1272.     move.l    Br_Old78(pc),$78(a0)
  1273.     move.w    d0,$dff0a8
  1274.     move.w    d0,$dff0b8
  1275.     move.w    d0,$dff0c8
  1276.     move.w    d0,$dff0d8
  1277.     move.l    (sp)+,a0
  1278.     rts
  1279.  
  1280. *****************************************************************************
  1281. Br_GetVBR:******************************  Get VBR procedure by XANN *********
  1282.     MOVEM.L    D0/A0/A5-A6,-(SP)    ; Only usable under DOS...
  1283.     LEA    Br_VBR(PC),A0
  1284.     MOVE.L    4.W,A6
  1285.     BTST    #0,296+1(A6)        ; AttnFlags.W >= 'Mc68010' ?
  1286.     BEQ.B    .Mc68000
  1287.     LEA    .StoreVBR(PC),A5
  1288.     PEA    .Mc680X0(PC)        ; Return Address for SV()'s RTS
  1289.     JMP    -30(A6)            ; Supervisor
  1290.  
  1291. .StoreVBR:
  1292.     Dc.L    $4E7A0801        ; MOVEC VBR,D0
  1293.     RTE
  1294.  
  1295. .Mc680X0:
  1296.     MOVE.L    D0,(A0)            ; Store VBR in [VectorBase].L
  1297. .Mc68000:
  1298.     MOVEM.L    (SP)+,D0/A0/A5-A6
  1299.     RTS
  1300.  
  1301. *****************************************************************************
  1302. ****************************************** Br Control Variables *************
  1303.  
  1304. Br_Infos:        dc.w    0    ; Status
  1305. Br_MaxPos:        dc.b    0
  1306. Br_MaxPat:        dc.b    0
  1307. Br_Module:        dc.l    0
  1308. Br_Song:        dc.l    0    ; Song address
  1309. Br_Sample:        dc.l    0    ; Samples start address
  1310. Br_Pattern:        dc.l    0    ; Pointeur sur la pattern
  1311. Br_Counter:        dc.w    0    ; Compteur de frame
  1312. Br_Position:        dc.w    0    ; Position dans la SONG
  1313. Br_Note:        dc.w    0    ; Position dans la PATTERN
  1314. Br_Break:        dc.w    0
  1315. Br_BreakSng:        dc.w    0
  1316. Br_DMACON:        dc.w    0
  1317. Br_LoopTest:        dc.w    0
  1318. Br_OldDMACON:        dc.w    0
  1319. Br_Old78:        dc.l    0
  1320. Br_VBR:            dc.l    0
  1321. Br_PtrnDelay:        dc.w    0
  1322. Br_LoopPatternVal:    dc.w    0
  1323. Br_LoopStartPos:    dc.w    0
  1324. Br_LoopStartAdr:    dc.l    0
  1325.  
  1326.             IFNE    Br_MasterVolumeControl
  1327. Br_MasterVolume:    dc.w    Br_Volume
  1328. Br_FadeVolume:        dc.w    0
  1329.             ENDC
  1330. Br_Speed:        dc.w    6
  1331. Br_Tempo:        dc.w    Br_TempoInit
  1332. Br_CIATimer:        dc.w    (Br_FrameValue/Br_TempoInit)-Br_ReplayTime
  1333.  
  1334. Br_StartPos:        dc.w    0
  1335. Br_StartNote:        dc.w    0
  1336.  
  1337. ;Br_ChPer        = 0    ; w    Offset
  1338. Br_ChVol        = 2    ; w
  1339. Br_ChAdr        = 4    ; l
  1340. Br_ChRP            = 8    ; l
  1341. Br_ChLen        = 12    ; w
  1342. Br_ChRLen        = 14    ; w
  1343. Br_ChEff        = 16    ; b
  1344. Br_ChCommand        = 17    ; b
  1345. Br_ChTempValue        = 18    ; w
  1346. Br_ChNote        = 20    ; w
  1347. Br_ChOldSample        = 22    ; w
  1348. Br_ChPortamento        = 24    ; w
  1349. Br_ChSampleOffset    = 26    ; w
  1350. Br_ChPortSource        = 28    ; w
  1351. Br_ChPortDest        = 30    ; w
  1352. Br_ChArp1        = 32    ; w
  1353. Br_ChArp2        = 34    ; w
  1354. Br_ChArp3        = 36    ; w
  1355. Br_ChVibratoSpeed    = 38    ; w
  1356. Br_ChVibratoDepth    = 40    ; w
  1357. Br_ChVibratoPos        = 42    ; w
  1358. Br_ChannelInfo:        ds.b    64*4    ; DS CLEAR option would be better...
  1359.  
  1360. ;Br_SplFine        = 0    ; b    Offset
  1361. Br_SplVol        = 1    ; b
  1362. Br_SplAdr        = 2    ; l
  1363. Br_SplRP        = 6    ; l
  1364. Br_SplLen        = 10    ; w
  1365. Br_SplRLen        = 12    ; w
  1366. Br_SplFineTablePtr    = 14    ; l
  1367. Br_SampleInfos:        ds.b    32*31
  1368.  
  1369. Br_Period0:
  1370.     dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  1371.     dc.w    428,404,381,360,339,320,302,285,269,254,240,226
  1372.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  1373.  
  1374.     dc.w    850,802,757,715,674,637,601,567,535,505,477,450
  1375.     dc.w    425,401,379,357,337,318,300,284,268,253,239,225
  1376.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  1377.  
  1378.     dc.w    844,796,752,709,670,632,597,563,532,502,474,447
  1379.     dc.w    422,398,376,355,335,316,298,282,266,251,237,224
  1380.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  1381.  
  1382.     dc.w    838,791,746,704,665,628,592,559,528,498,470,444
  1383.     dc.w    419,395,373,352,332,314,296,280,264,249,235,222
  1384.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  1385.  
  1386.     dc.w    832,785,741,699,660,623,588,555,524,495,467,441
  1387.     dc.w    416,392,370,350,330,312,294,278,262,247,233,220
  1388.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  1389.  
  1390.     dc.w    826,779,736,694,655,619,584,551,520,491,463,437
  1391.     dc.w    413,390,368,347,328,309,292,276,260,245,232,219
  1392.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  1393.  
  1394.     dc.w    820,774,730,689,651,614,580,547,516,487,460,434
  1395.     dc.w    410,387,365,345,325,307,290,274,258,244,230,217
  1396.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  1397.  
  1398.     dc.w    814,768,725,684,646,610,575,543,513,484,457,431
  1399.     dc.w    407,384,363,342,323,305,288,272,256,242,228,216
  1400.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  1401.  
  1402.     dc.w    907,856,808,762,720,678,640,604,570,538,508,480
  1403.     dc.w    453,428,404,381,360,339,320,302,285,269,254,240
  1404.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  1405.  
  1406.     dc.w    900,850,802,757,715,675,636,601,567,535,505,477
  1407.     dc.w    450,425,401,379,357,337,318,300,284,268,253,238
  1408.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  1409.  
  1410.     dc.w    894,844,796,752,709,670,632,597,563,532,502,474
  1411.     dc.w    447,422,398,376,355,335,316,298,282,266,251,237
  1412.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  1413.  
  1414.     dc.w    887,838,791,746,704,665,628,592,559,528,498,470
  1415.     dc.w    444,419,395,373,352,332,314,296,280,264,249,235
  1416.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  1417.  
  1418.     dc.w    881,832,785,741,699,660,623,588,555,524,494,467
  1419.     dc.w    441,416,392,370,350,330,312,294,278,262,247,233
  1420.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  1421.  
  1422.     dc.w    875,826,779,736,694,655,619,584,551,520,491,463
  1423.     dc.w    437,413,390,368,347,328,309,292,276,260,245,232
  1424.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  1425.  
  1426.     dc.w    868,820,774,730,689,651,614,580,547,516,487,460
  1427.     dc.w    434,410,387,365,345,325,307,290,274,258,244,230
  1428.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  1429.  
  1430.     dc.w    862,814,768,725,684,646,610,575,543,513,484,457
  1431.     dc.w    431,407,384,363,342,323,305,288,272,256,242,228
  1432.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  1433.  
  1434. Br_VibratoTable:    
  1435.     dc.w    0,24,49,74,97,120,141,161
  1436.     dc.w    180,197,212,224,235,244,250,253
  1437.     dc.w    255,253,250,244,235,224,212,197
  1438.     dc.w    180,161,141,120,97,74,49,24
  1439.     dc.w    0,-24,-49,-74,-97,-120,-141,-161
  1440.     dc.w    -180,-197,-212,-224,-235,-244,-250,-253
  1441.     dc.w    -255,-253,-250,-244,-235,-224,-212,-197
  1442.     dc.w    -180,-161,-141,-120,-97,-74,-49,-24
  1443.  
  1444. Br_EventTable:
  1445.     ds.w    16
  1446. Br_Length=*-Br_Start
  1447.  
  1448.     SECTION    Module,DATA_C
  1449. Mod:    incdir    work:exrunner/modules/
  1450.     incbin    mod.bonus
  1451.